#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
typedef unsigned long long ULL;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=1e5+10,MAXM=320;
int n,q,m,bloc,w[MAXN],head[MAXN],cnt,st[MAXN],ed[MAXN],cunt[MAXN],rt,belog[MAXN],f[MAXM][MAXN],tim;
ULL sum[MAXM];
struct BIT
{
	ULL num[MAXN];
	inline int lowbit(int x)
	{
		return x&-x;
	}
	void update(int o,int x)
	{
		while(o<=n)
		{
			num[o]+=x;
			o+=lowbit(o);
		}
		return;
	}
	ULL query(int o)
	{
		ULL ret=0;
		while(o)
		{
			ret+=num[o];
			o-=lowbit(o);
		}
		return ret;
	}
}T1;
struct edge
{
	int v,next;
}e[MAXN<<1];
void addedge(int x,int y)
{
	e[++cnt]=(edge){y,head[x]};
	head[x]=cnt;
	return;
}
void dfs(int u,int lst)
{
	++cunt[belog[u]];
	for(int i=1;i<=m;++i)f[i][u]+=cunt[i];
	st[u]=++tim;
	for(int i=head[u];i;i=e[i].next)
	{
		int v=e[i].v;
		if(v!=lst)dfs(v,u);
	}
	ed[u]=tim;
	--cunt[belog[u]];
	return;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=read();q=read();
	bloc=sqrt(n);
	m=(n-1)/bloc+1;
	for(int i=1;i<=n;++i)w[i]=read();
	for(int i=1;i<=n;++i)
	{
		int x=read(),y=read();
		if(!x)rt=y;
		else addedge(x,y),addedge(y,x);
		belog[i]=(i-1)/bloc+1;
	}
	dfs(rt,0);
	for(int i=1;i<=n;++i)T1.update(st[i],w[i]);
	for(int i=1;i<=m;++i)
	{
		int l=(i-1)*bloc+1,r=min(i*bloc,n);
		for(int j=l;j<=r;++j)sum[i]+=T1.query(ed[j])-T1.query(st[j]-1);
	}
	while(q--)
	{
		int op=read();
		if(op==1)
		{
			int x=read(),y=read();
			T1.update(st[x],y-w[x]);
			for(int i=1;i<=m;++i)sum[i]+=(ULL)f[i][x]*(y-w[x]);
			w[x]=y;
		}
		else 
		{
			int l=read(),r=read();
			ULL ans=0;
			if(belog[l]==belog[r])
				for(int i=l;i<=r;++i)ans+=T1.query(ed[i])-T1.query(st[i]-1);
			else
			{
				int k=belog[l]*bloc;
				for(int i=l;i<=k;++i)ans+=T1.query(ed[i])-T1.query(st[i]-1);
				for(int i=belog[l]+1;i<belog[r];++i)ans+=sum[i];
				for(int i=(belog[r]-1)*bloc+1;i<=r;++i)ans+=T1.query(ed[i])-T1.query(st[i]-1);
			}
			printf("%llu\n",ans);
		}
	}
	return 0;
}
